//
//  WCBTextField.m
//  WeChatBuniess
//
//  Created by Guo Rui on 2017/12/14.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "WCBTextField.h"

@interface WCBTextField()

@end
@implementation WCBTextField

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.borderColor = [UIColor lightGrayColor].CGColor;
        self.layer.borderWidth = 1.f;
        self.layer.cornerRadius = 3.f;
        self.layer.masksToBounds = YES;
        
        self.tintColor = [UIColor lightGrayColor];
    }
    return self;
}

- (void)setM_boderColor:(UIColor *)m_boderColor
{
    _m_boderColor = m_boderColor;
    self.layer.borderColor = m_boderColor.CGColor;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    self.layer.borderColor = [UIColor colorWithRed:0.11 green:0.62 blue:0.94 alpha:1.00].CGColor;
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    self.layer.borderColor = [UIColor lightGrayColor].CGColor;
}

- (void)drawTextInRect:(CGRect)rect
{
    rect.origin.x += 10;
    rect.size.width -= 10;
    [super drawTextInRect:rect];
}

- (void)drawPlaceholderInRect:(CGRect)rect
{
    rect.origin.x += 10;
    rect.size.width -= 10;
    [super drawPlaceholderInRect:rect];
}

- (CGRect)editingRectForBounds:(CGRect)bounds
{
    CGFloat x, y = 0;
    x = 20;
    return CGRectMake(x, y, bounds.size.width - x, bounds.size.height);
}

- (CGRect)textRectForBounds:(CGRect)bounds
{
    CGFloat x, y = 0;
    x = 10;
    return CGRectMake(x, y, bounds.size.width - x, bounds.size.height);
}


@end
